package com.liunian.algorithmstudy.tree;

import java.util.ArrayList;
import java.util.List;

public class BinaryTreePaths257 extends TreeNode {

	private List<String> res = new ArrayList<>();
	public List<String> binaryTreePaths(TreeNode root) {
		travelsal(root, "");
		return res;
	}

	private void travelsal(TreeNode root, String str) {
		str += ("->" + root.val);
		if (root.left == null && root.right == null) {
			res.add(str.substring(2));
			return;
		}
		if (root.left != null) {
			travelsal(root.left, str);
		}
		if (root.right != null) {
			travelsal(root.right, str);
		}
	}

}
